home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C++ / Frameworks / Sprocket Framework DR2 / Sprocket Framework / SplashWindow.cp < prev    next >
Text File  |  1996-06-15  |  3KB  |  117 lines

  1. /*
  2.  
  3.     File:        SplashWindow.cp
  4.     Project:    Sprocket Framework 1.1 (DR2), released 6/15/96
  5.     Contains:    Sub-class of TWindow which handles a splash screen
  6.     To Do:        This may become optional in future Sprockets
  7.  
  8.     Sprocket Major Contributors:
  9.     ----------------------------
  10.     Dave Falkenburg, producer of Sprocket 1.0
  11.     Bill Hayden,     producer of Sprocket 1.1
  12.     Steve Sisak,     producer of the upcoming Sprocket 2.0
  13.     
  14.     Pete Alexander        Steve Falkenburg    Randy Thelen
  15.     Eric Berdahl        Nitin Ganatra        Chris K. Thomas
  16.     Marshall Clow        Dave Hershey        Leonard Rosenthal
  17.     Tim Craycroft        Dave Mark            Dean Yu
  18.     David denBoer        Gary Powell
  19.     Cameron Esfahani    Jon Summers            Apple Computer, Inc.
  20.         
  21.     Comments, Additions, or Corrections:
  22.     ------------------------------------
  23.     Bill Hayden, Nikol Software <nikol@codewell.com>
  24.  
  25. */
  26.  
  27. #include "SprocketConstants.h"
  28. #include "SplashWindow.h"
  29. #include "UString.h"
  30.  
  31. #include <ToolUtils.h>
  32.  
  33.  
  34. TSplashWindow::TSplashWindow()
  35. {
  36.     this->CreateWindow(kNormalWindow);
  37.     pcpy(fStatus, "\pStarting up…");
  38. }
  39.  
  40.  
  41. TSplashWindow::~TSplashWindow()
  42. {
  43.     if (fSplashPicture)
  44.         ReleaseResource((Handle)fSplashPicture);
  45.     
  46.     this->Close();
  47. }
  48.  
  49.  
  50. WindowRef TSplashWindow::MakeNewWindow(WindowRef behindWindow)
  51. {
  52.     GrafPtr        oldPort;
  53.     Rect        windowRect;
  54.     WindowRef    splashWindow;
  55.     
  56.     GetPort(&oldPort);
  57.  
  58.     fSplashPicture = GetPicture(kSplashPictureID);
  59.     
  60.     if (fSplashPicture)
  61.         {
  62.         MoveHHi((Handle) fSplashPicture);                        //    get it out of the way
  63.         fSplashPictRect = (**fSplashPicture).picFrame;
  64.         }
  65.     else
  66.         SetRect(&fSplashPictRect, 0, 0, 0, 0);
  67.         
  68.     //    normalize the rectangle
  69.     OffsetRect(&fSplashPictRect, -fSplashPictRect.left, -fSplashPictRect.top);
  70.  
  71.     //    center it on the main screen
  72.     
  73.     fStatusRect = fSplashPictRect;
  74.     fStatusRect.top = fStatusRect.bottom + 6;
  75.     fStatusRect.bottom += 18;
  76.     InsetRect(&fStatusRect, 6, 0);
  77.     
  78.     windowRect = fSplashPictRect;
  79.     windowRect.bottom += 24;
  80.     OffsetRect(&windowRect,((qd.screenBits.bounds.right-windowRect.right) >> 1),((qd.screenBits.bounds.bottom-windowRect.bottom) >> 1));
  81.     
  82.     splashWindow = NewColorOrBlackAndWhiteWindow(nil,&windowRect,(StringPtr) "\p",false,dBoxProc,behindWindow,false,(long) this);
  83.     ShowWindow(splashWindow);
  84.         
  85.     SetPort(oldPort);
  86.     return splashWindow;
  87. }
  88.  
  89.  
  90. void TSplashWindow::Draw()
  91. {
  92.     //BeginUpdate(fWindow);                    //    avoid a flashing update event later
  93.  
  94.     SetPortWindowPort(fWindow);
  95.     
  96.     TextFont(geneva);
  97.     TextSize(9);
  98.     TextFace(bold);
  99.     
  100.     TETextBox(&fStatus[0] + 1, fStatus[0], &fStatusRect, teCenter);
  101.     if (fSplashPicture)
  102.         DrawPicture(fSplashPicture, &fSplashPictRect);
  103.  
  104.     //EndUpdate(fWindow);                    //    avoid a flashing update event later    
  105. }
  106.  
  107.  
  108. void TSplashWindow::NewStatus(StringPtr status)
  109. {
  110.     pcpy(fStatus, status);
  111.     
  112.     this->Draw();
  113. }
  114.  
  115.  
  116.  
  117.